$(document).ready(function(){
	$("#functionNav").attr("href",navAddr);
  //获取url中的参数
  var djbh =GetQueryString("djbh"); 
  
  //初始化征集信息
  ajaxFunc("post",false,'antiques/zjquery.getDjDetail.do?djbh='+djbh,"",setDetail,"form_detail");	
  //初始化藏品清单Table
  createTable('#cptbl','antiques/zjquery.getDjCangPinList.do?djbh='+djbh,'id',cptblColumns,{'djbh':djbh});
  //初始化附件Table
  createTable('#attachmentstbl','antiques/zjquery.getFileList.do?djbh='+djbh,'id',attachmentstblColumns,{'djbh':djbh});
  //初始化审批意见信息
  ajaxFunc("post",false,'antiques/zjquery.getCommentList.do?djbh='+djbh,"",setComment,"form_comment");
})

//设置详细信息
function setDetail(allData,domId){
	loadData("#"+domId,allData.data[0]);
}
//设置审批意见
function setComment(data,domId){
	console.log(data.data);
	$.each(data.data,function(i,row){
		if(row.yjnr !=""){
			var info = row.yjnr + '\n' + row.yjrmc + "  " + row.yjsj + "\n";
		}
		switch(row.yjlx){
			case "申请意见":{
				$("#"+domId+" #sqyj").val($("#"+domId+" #sqyj").val()+info);
				break;
			}
			case "部门主任意见":{
				$("#"+domId+" #jdbzryj").val($("#"+domId+" #jdbzryj").val()+info);
				break;
			}
			case "分管馆长意见":{
				$("#"+domId+" #fggzyj").val($("#"+domId+" #fggzyj").val()+info);
				break;
			}
			case "馆长意见":{
				$("#"+domId+" #zgzyj").val($("#"+domId+" #zgzyj").val()+info);
				break;
			}
			case "总账管理员意见":{
				$("#"+domId+" #zzglyyj").val($("#"+domId+" #zzglyyj").val()+info);
				break;
			}
		}
	})
}

//藏品列表table表头
var cptblColumns=[{
    field: 'DJBH',
    title: '征集单号'
  }, {
	    field: 'RGH',
	    title: '入馆号'
  }, {
    field: 'MC',
    title: '名称',
    formatter: function(value, row, index) {
	  	  return '<a href="zhengJiInfo.html?djbh='+row.DJBH+'&id='+row.ID+'">'+value+'</a>';
	  	}
  }, {
    field: 'LYLXNAME',
    title: '来源类型'
  }, {
    field: 'SD1',
    title: '时代',
    formatter:function(value, row, index) {
    	if(row.SD4!="")
    		return row.SD4;
    	else if(row.SD4=="" && row.SD3!="")
    		return row.SD3;
    	else if(row.SD3=="" && row.SD2!="")
    		return row.SD2;
    	else
    		return row.SD1;
    }
  }, {
	    field: 'CTSL',
	    title: '传统数量',
	    formatter: function(value, row, index) {
	  	  return value + row.CTSLDW;
	  	}
	  }, {
    field: 'SJSL',
    title: '实际数量',
    formatter: function(value, row, index) {
	  	  return value + row.SJSLDW;
	  	}
  }];

//附件table表头
var attachmentstblColumns=[{
    field: 'wjmc',
    title: '文件名'
}, {
    field: 'filesize',
    title: '文件大小'
},{
    field: 'lrrmc',
    title: '上传人'
},  {
    field: 'lrsj',
    title: '上传日期'
}, {
    field: '',
    title: '操作',
    formatter: function(value, row, index) {
    	return "<a onclick='window.open(\""+downloadAddr+row.wjdz+"\")' href='javascript:void(0)'>下载</a>";        	
     }
}]